/**
 * 
 */
package ar.edu.unq.svnpermission.panels;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

/**
 * @author nicolas
 *
 */
public abstract class LinkPanel<T> extends Panel {

	private static final long serialVersionUID = 1L;
	
	public LinkPanel(String id,IModel<T> model,String label) {
		super(id,model);
        AjaxFallbackLink<T> link  = new AjaxFallbackLink<T>("link") {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                LinkPanel.this.onClick(target);
            }

	    };
	    add(link);
	
	
	    link.add(new Label("text", label));		
	}
	
	public abstract void onClick(AjaxRequestTarget target);
	
	@SuppressWarnings("unchecked")
	public final T getModelObject()
	{
		return (T)getDefaultModelObject();
	}

	

}
